
package edu.usc.cmb.iregulome.client;

import java.net.MalformedURLException;
import java.util.Collection;
import java.util.HashMap;
import javax.xml.namespace.QName;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.aegis.AegisBindingProvider;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;

public class eUtilsServiceClient {

    private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
    private HashMap endpoints = new HashMap();
    private Service service0;

    public eUtilsServiceClient() {
        create0();
        Endpoint eUtilsServiceSoapLocalEndpointEP = service0 .addEndpoint(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoapLocalEndpoint"), new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoapLocalBinding"), "xfire.local://eUtilsService");
        endpoints.put(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoapLocalEndpoint"), eUtilsServiceSoapLocalEndpointEP);
        Endpoint eUtilsServiceSoapEP = service0 .addEndpoint(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoap"), new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoap"), "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/soap_adapter_2_0.cgi");
        endpoints.put(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoap"), eUtilsServiceSoapEP);
    }

    public Object getEndpoint(Endpoint endpoint) {
        try {
            return proxyFactory.create((endpoint).getBinding(), (endpoint).getUrl());
        } catch (MalformedURLException e) {
            throw new XFireRuntimeException("Invalid URL", e);
        }
    }

    public Object getEndpoint(QName name) {
        Endpoint endpoint = ((Endpoint) endpoints.get((name)));
        if ((endpoint) == null) {
            throw new IllegalStateException("No such endpoint!");
        }
        return getEndpoint((endpoint));
    }

    public Collection getEndpoints() {
        return endpoints.values();
    }

    private void create0() {
        TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager());
        HashMap props = new HashMap();
        props.put("annotations.allow.interface", true);
        AnnotationServiceFactory asf = new AnnotationServiceFactory(new Jsr181WebAnnotations(), tm, new AegisBindingProvider(new JaxbTypeRegistry()));
        asf.setBindingCreationEnabled(false);
        service0 = asf.create((edu.usc.cmb.iregulome.client.eUtilsServiceSoap.class), props);
        {
            AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoapLocalBinding"), "urn:xfire:transport:local");
        }
        {
            AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoap"), "http://schemas.xmlsoap.org/soap/http");
        }
    }

    public eUtilsServiceSoap geteUtilsServiceSoapLocalEndpoint() {
        return ((eUtilsServiceSoap)(this).getEndpoint(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoapLocalEndpoint")));
    }

    public eUtilsServiceSoap geteUtilsServiceSoapLocalEndpoint(String url) {
        eUtilsServiceSoap var = geteUtilsServiceSoapLocalEndpoint();
        org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
        return var;
    }

    public eUtilsServiceSoap geteUtilsServiceSoap() {
        return ((eUtilsServiceSoap)(this).getEndpoint(new QName("http://www.ncbi.nlm.nih.gov/soap/eutils/", "eUtilsServiceSoap")));
    }

    public eUtilsServiceSoap geteUtilsServiceSoap(String url) {
        eUtilsServiceSoap var = geteUtilsServiceSoap();
        org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
        return var;
    }

}
